home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / NumberFormatting.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  3.6 KB  |  153 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        NumberFormatting.p
  3.  
  4.      Contains:    Utilites for formatting numbers
  5.  
  6.      Version:    Technology:    
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT NumberFormatting;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __NUMBERFORMATTING__}
  27. {$SETC __NUMBERFORMATTING__ := 1}
  28.  
  29. {$I+}
  30. {$SETC NumberFormattingIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __CONDITIONALMACROS__}
  34. {$I ConditionalMacros.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MACTYPES__}
  37. {$I MacTypes.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __INTLRESOURCES__}
  40. {$I IntlResources.p}
  41. {$ENDC}
  42.  
  43.  
  44.  
  45. {$PUSH}
  46. {$ALIGN MAC68K}
  47. {$LibExport+}
  48.  
  49. {
  50.  
  51.     Here are the current System 7 routine names and the translations to the older forms.
  52.     Please use the newer forms in all new code and migrate the older names out of existing
  53.     code as maintainance permits.
  54.     
  55.     New Name                    Old Name(s)
  56.     
  57.     ExtendedToString            FormatX2Str
  58.     FormatRecToString            Format2Str
  59.     NumToString                
  60.     StringToExtended            FormatStr2X
  61.     StringToFormatRec            Str2Format
  62.     StringToNum                
  63.  
  64. }
  65.  
  66. TYPE
  67.     NumFormatStringPtr = ^NumFormatString;
  68.     NumFormatString = PACKED RECORD
  69.         fLength:                UInt8;
  70.         fVersion:                UInt8;
  71.         data:                    PACKED ARRAY [0..253] OF CHAR;            {  private data  }
  72.     END;
  73.  
  74.     NumFormatStringRec                    = NumFormatString;
  75.     NumFormatStringRecPtr                 = ^NumFormatStringRec;
  76.     FormatStatus                        = INTEGER;
  77.  
  78. CONST
  79.     fVNumber                    = 0;                            {  first version of NumFormatString  }
  80.  
  81.  
  82. TYPE
  83.     FormatClass                            = SInt8;
  84.  
  85. CONST
  86.     fPositive                    = 0;
  87.     fNegative                    = 1;
  88.     fZero                        = 2;
  89.  
  90.  
  91. TYPE
  92.     FormatResultType                    = SInt8;
  93.  
  94. CONST
  95.     fFormatOK                    = 0;
  96.     fBestGuess                    = 1;
  97.     fOutOfSynch                    = 2;
  98.     fSpuriousChars                = 3;
  99.     fMissingDelimiter            = 4;
  100.     fExtraDecimal                = 5;
  101.     fMissingLiteral                = 6;
  102.     fExtraExp                    = 7;
  103.     fFormatOverflow                = 8;
  104.     fFormStrIsNAN                = 9;
  105.     fBadPartsTable                = 10;
  106.     fExtraPercent                = 11;
  107.     fExtraSeparator                = 12;
  108.     fEmptyFormatString            = 13;
  109.  
  110.  
  111. TYPE
  112.     FVectorPtr = ^FVector;
  113.     FVector = RECORD
  114.         start:                    INTEGER;
  115.         length:                    INTEGER;
  116.     END;
  117.  
  118. { index by [fPositive..fZero] }
  119.     TripleInt                            = ARRAY [0..2] OF FVector;
  120. PROCEDURE StringToNum(theString: Str255; VAR theNum: LONGINT);
  121. PROCEDURE NumToString(theNum: LONGINT; VAR theString: Str255);
  122.  
  123. FUNCTION ExtendedToString({CONST}VAR x: extended80; {CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR outString: Str255): FormatStatus;
  124.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  125.     INLINE $2F3C, $8210, $FFE8, $A8B5;
  126.     {$ENDC}
  127. FUNCTION StringToExtended(source: Str255; {CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR x: extended80): FormatStatus;
  128.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  129.     INLINE $2F3C, $8210, $FFE6, $A8B5;
  130.     {$ENDC}
  131. FUNCTION StringToFormatRec(inString: Str255; {CONST}VAR partsTable: NumberParts; VAR outString: NumFormatString): FormatStatus;
  132.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  133.     INLINE $2F3C, $820C, $FFEC, $A8B5;
  134.     {$ENDC}
  135. FUNCTION FormatRecToString({CONST}VAR myCanonical: NumFormatString; {CONST}VAR partsTable: NumberParts; VAR outString: Str255; VAR positions: TripleInt): FormatStatus;
  136.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  137.     INLINE $2F3C, $8210, $FFEA, $A8B5;
  138.     {$ENDC}
  139.  
  140. {$IFC OLDROUTINENAMES }
  141. {$ENDC}  {OLDROUTINENAMES}
  142.  
  143. {$ALIGN RESET}
  144. {$POP}
  145.  
  146. {$SETC UsingIncludes := NumberFormattingIncludes}
  147.  
  148. {$ENDC} {__NUMBERFORMATTING__}
  149.  
  150. {$IFC NOT UsingIncludes}
  151.  END.
  152. {$ENDC}
  153.